#include "stdafx.h"
#include "dll_object.h"
#include "cfg_wrapper.h"

cfg_wrapper::cfg_wrapper()
{

}

void 
cfg_wrapper::init_interface(aot::glb::cfg_mgr_help* help)
{
	this->cfg_mgr_help_ = help;
}

aot::glb::cfg_mgr_help* 
cfg_wrapper::get_interface()
 {
 
 	return this->cfg_mgr_help_;
 }

bool 
cfg_wrapper::read(const char *user_id)
{
	this->cfg_mgr_help_->read(user_id);
	return true;
}

bool 
cfg_wrapper::save()
{
	std::vector<setting_info_t>::iterator iter = this->setting_info_.begin();
	for ( ; iter != this->setting_info_.end(); iter++ )
	{
		if ( ::SendMessage((*iter).dlg->m_hWnd, WM_SAVE_SETTING, (int)(*iter).value_type, 0) == -1 )
			return false;
	}
	this->setting_info_.clear();
	return true;
}

bool
cfg_wrapper::write()
{
	bool b = this->cfg_mgr_help_->write();
	//return this->cfg_mgr_help_->write();
	return b;
}

void 
cfg_wrapper::insert_setting_info(CDialog *dlg, int value_type)
{
	std::vector<setting_info_t>::iterator iter = this->setting_info_.begin();
	for ( ; iter != this->setting_info_.end(); iter++ )
	{
		if ( (*iter).value_type == value_type )
		{
			return;
		}
	}
	setting_info_t info;
	info.dlg = dlg;
	info.value_type = value_type;
	this->setting_info_.push_back(info);
}